$(function(){
    var interval;
    $(document).ajaxStart(function(){
        $.blockUI({
            message: $("#loading"), 
            css: { 
                top:  ($(window).height()- 170) /2 + "px", 
                left: ($(window).width() - 400) /2 + "px", 
                width: "400px",
                border: "none"
            },
            overlayCSS: { backgroundColor: "#FFFFFF" }
        });
    }).ajaxStop($.unblockUI);
    
    
    $("#refresh").click(function(){
        var flag = $(this).prop("checked");
        if(flag){
            interval = window.setInterval(refreshContent, 10000);
        }else{
            window.clearInterval(interval);
        }
    });
});

function formatDate(time){
    var date = new Date(time);
    var year = date.getFullYear(),
        month = date.getMonth() + 1,//月份是从0开始的
        day = date.getDate(),
        hour = date.getHours(),
        min = date.getMinutes(),
        sec = date.getSeconds();
    if(month < 10){
        month = "0" + month;
    }
    if(day < 10){
        day = "0" + day;
    }
    if(hour < 10){
        hour = "0" + hour;
    }
    if(min < 10){
        min = "0" + min;
    }
    if(sec < 10){
        sec = "0" + sec;
    }
    var newTime = year + '/' +
                month + '/' +
                day + ' ' +
                hour + ':' +
                min + ':' +
                sec;
    return newTime;
}


